﻿

namespace FinQ
{

    /// <summary>
    /// Sam's functional programming library. F'LINQ!
    /// </summary>
    static partial class Functional
    {
        // this is not a predicate, it's a function builder like curry
        // inverts a predicate function
        public static Pred<T> NotP<T>(Pred<T> f)
        {
            return x => !f(x);
        }

        public static bool OddP(int a)
        {
            return (a & 1) == 1;
        }

        public static bool EvenP(int a)
        {
            return !OddP(a);
        }

        public static int Add1(int a) { return a + 1; }
        public static decimal Add1(decimal a) { return a + 1; }
        public static double Add1(double a) { return a + 1; }
        public static float Add1(float a) { return a + 1; }

        public static int Double(int a) { return a * 2; }
        public static decimal Double(decimal a) { return a * 2; }
        public static double Double(double a) { return a * 2; }
        public static float Double(float a) { return a * 2; }

        public static int Square(int a) { return a * a; }
        public static decimal Square(decimal a) { return a * a; }
        public static double Square(double a) { return a * a; }
        public static float Square(float a) { return a * a; }

        public static int Cube(int a) { return a * a * a; }
        public static decimal Cube(decimal a) { return a * a * a; }
        public static double Cube(double a) { return a * a * a; }
        public static float Cube(float a) { return a * a * a; }

    }
}